import router from '@/router/index'
import { userStore } from '@/store/user'

router.beforeEach((to, form, next) => {
  const { token } = userStore()

  if (!token) {
    if (to.path === '/login') {
      next()
    }
    next('/login')
  } else {
    if (to.path === '/login') {
      next('/')
    }
    next()
  }
})
